Vectors

Vectors are heterogenous structures whose elements are indexed by integers. A vector typically occupies less space than a list of the same length, and the average time required to access a randomly chosen element is typically less for the vector than for the list.

The <#1516#>length<#1516#> of a vector is the number of elements that it contains. This number is a non-negative integer that is fixed when the vector is created. The <#1517#>valid indexes<#1517#> of a vector are the exact non-negative integers less than the length of the vector. The first element in a vector is indexed by zero, and the last element is indexed by one less than the length of the vector.

Vectors are written using the notation <#2193#>#(<#1519#>obj<#1519#> )<#2193#>. For example, a vector of length 3 containing the number zero in element 0, the list <#1520#>(2 2 2 2)<#1520#> in element 1, and the string <#1521#>;SPMquot;Anna;SPMquot;<#1521#> in element 2 can be written as following:


#scheme1522#

Note that this is the external representation of a vector, not an expression evaluating to a vector. Like list constants, vector constants must be quoted:


#scheme1524#

<#1526#>Pitman sez: The visual similarity to lists is bound to be confusing to some. Elaborate on the distinction.<#1526#>


#entry1527#


#entry1534#


#entry1544#


#entry1552#


#entry1558#


#entry1570#


#entry1584#


#entry1598#